package com.eurake.seckill.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eurake.seckill.Exception.GlobalException;
import com.eurake.seckill.mapper.GoodsMapper;
import com.eurake.seckill.pojo.Goods;
import com.eurake.seckill.service.IGoodsService;
import com.eurake.seckill.vo.GoodsVo;
import com.eurake.seckill.vo.RespBeanEnum;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chen
 * @since 2024-11-24
 */
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements IGoodsService {
    @Resource
    private GoodsMapper goodsMapper;

    @Override
    public List<GoodsVo> findGoodsVo() {
        return goodsMapper.findGoodsVo();
    }

    @Override
    public GoodsVo findGoodsVoByGoodsId(long goodsId) {
        GoodsVo goodsVo = goodsMapper.findGoodsVoByGoodsId(goodsId);
        if(goodsVo == null){
            throw new GlobalException(RespBeanEnum.Goods_NOT_FIND);
        }
        return goodsVo;
    }
}
